package com.invengo.module_check.ui.fragment.home;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.navigation.fragment.NavHostFragment;

import com.invengo.module_check.BR;
import com.invengo.module_check.R;
import com.invengo.module_check.data.entity.BundleKey;
import com.invengo.module_check.databinding.FragmentHomeBinding;

import me.goldze.mvvmhabit.base.BaseFragment;

public class HomeFragment extends BaseFragment<FragmentHomeBinding, HomeViewModel> {
    Bundle bundle = new Bundle();

    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_home;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public String getRightTitle() {
        return "设置";
    }

    @Override
    public void onRightEvent(View view) {
        bundle.putBoolean(BundleKey.KEY_FROM_HOME, true);
        NavHostFragment.findNavController(this).navigate(R.id.homefragment_2_settingFragment,bundle );
    }

    @Override
    public void initViewObservable() {
        viewModel.itemClickEvent.observe(this, featureBean -> {
            bundle.putSerializable(BundleKey.KEY_ACTION, featureBean.getActionArgs());
            NavHostFragment.findNavController(this).navigate(featureBean.getActionArgs().getHome2first(), bundle);
        });
    }
}
